package com.example.demo.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class UserController {
    // 1. 得到日志对象
    private static final Logger logger = LoggerFactory.getLogger(UserController.class);

    @RequestMapping("/hi")
    @ResponseBody
    public String sayHi() {
        System.out.println();

        // 2. 使用日志对象打印日志
        logger.trace("日志级别：trace");
        logger.debug("日志级别：debug");
        logger.info("日志级别：info");
        logger.warn("日志级别：warn");
        logger.error("日志级别：error");

        System.out.println();

        return "Hello, ";
    }
}
